<template>
  <div class="bottom-navigation">
    <div 
      v-for="item in navItems" 
      :key="item.path"
      class="nav-item"
      :class="{ active: isActive(item.path) }"
      @click="handleNavClick(item.path)"
    >
      <img 
        class="nav-icon" 
        :src="getIconPath(item.icon)" 
        :alt="item.label + ' icon'"
      />
      <span class="nav-label">{{ item.label }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useRouter, useRoute } from 'vue-router'

const router = useRouter()
const route = useRoute()

// 导航项配置
const navItems = [
  {
    path: '/square',
    label: '广场',
    icon: 'square'
  },
  {
    path: '/show',
    label: '数据报表',
    icon: 'show'
  },
  {
    path: '/manager',
    label: '店铺管理',
    icon: 'manager'
  },
  {
    path: '/order',
    label: '订单管理',
    icon: 'order'
  },
  {
    path: '/chat',
    label: '聊天消息',
    icon: 'chat'
  },
  {
    path: '/user',
    label: '个人中心',
    icon: 'user'
  }
]

const getIconPath = (iconName: string) => {
  const suffix = isActive(iconName) ? '-active' : ''
  return `/${iconName}${suffix}.png`
}

const isActive = (path: string) => {
  if (path === '/') return route.path === '/'
  return route.path.startsWith(path)
}

const handleNavClick = (path: string) => {
  if (route.path !== path) router.push(path)
}
</script>

<style scoped>
.nav-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  margin-bottom: 4px;
  transition: all 0.3s ease;
}

.nav-item.active .nav-icon {
  transform: scale(1.1);
  filter: invert(48%) sepia(92%) saturate(2476%) hue-rotate(320deg) brightness(95%) contrast(91%);
}

.bottom-navigation {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: white;
  border-top: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 1000;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 8px;
  min-width: 60px;
}

.nav-item:hover {
  background: rgba(233, 30, 99, 0.1);
}

.nav-item.active {
  color: #e91e63;
}

.nav-item.active .nav-icon {
  color: #e91e63;
  transform: scale(1.1);
}

.nav-icon {
  font-size: 20px;
  color: #6c757d;
  margin-bottom: 4px;
  transition: all 0.3s ease;
}

.nav-label {
  font-size: 12px;
  color: #6c757d;
  transition: color 0.3s ease;
}

.nav-item.active .nav-label {
  color: #e91e63;
  font-weight: 500;
}

:global(body) {
  padding-bottom: 140px;
}

@media (max-width: 768px) {
  .bottom-navigation {
    height: 56px;
  }
  
  .nav-item {
    padding: 6px 12px;
    min-width: 50px;
  }
  
  .nav-icon {
    font-size: 18px;
  }
  
  .nav-label {
    font-size: 11px;
  }
  
  :global(body) {
    padding-bottom: 56px;
  }
}
</style> 